import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.net.URL;
import java.util.ArrayList;

import javax.imageio.ImageIO;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JSlider;
import javax.swing.JTabbedPane;
import javax.swing.JTextPane;
import javax.swing.border.LineBorder;

import org.rsbot.event.events.ServerMessageEvent;
import org.rsbot.event.listeners.PaintListener;
import org.rsbot.event.listeners.ServerMessageListener;
import org.rsbot.script.Script;
import org.rsbot.script.ScriptManifest;
import org.rsbot.script.methods.Bank;
import org.rsbot.script.methods.Game;
import org.rsbot.script.methods.Magic;
import org.rsbot.script.methods.Skills;
import org.rsbot.script.wrappers.GEItemInfo;
import org.rsbot.script.wrappers.RSComponent;
import org.rsbot.script.wrappers.RSInterface;
import org.rsbot.script.wrappers.RSObject;
import org.rsbot.script.wrappers.RSPlayer;
import org.rsbot.script.wrappers.RSTile;

	/* @Updated 9.24.2010.
	*
	* The client was updated so I had to update the withdrawal method.
	* 
	*/

@ScriptManifest(authors = { "Fallen" }, keywords = "Magic", name = "Fallen's Superheater", version = 5.03,
		description = "Superheats any kind of bars.")

public class FallenSuperheater extends Script implements PaintListener,
		ServerMessageListener, MouseListener, MouseMotionListener {
	
	private enum State {
		OPENBANK, BANK, SUPERHEAT
	}
	//Mostly paint int's
	boolean renew;
	public long logOutTime;
	public int status;
	public long startTime = 0;
	private long scriptStartTime = 0;
	private long runTime = 0;
	private long millis = 0;
	private long seconds = 0;
	private long minutes = 0;
	private long hours = 0;
	public int BarCounter = 0;	
	private int startXPM;
	private int startXPS;
	public int startLevelM;
	public int levelsGainedM;
	public int startLevelS;
	public int levelsGainedS;
	public int currentLevelM;
	public int currentLevelS;
	public Image BKG;
	public Image Timer;
	public int toNextLvlS;
	public int nextLvlS;
	public int XPToLevelS;
	public int toNextLvlM;
	public int nextLvlM;
	public int XPToLevelM;
	
	public int BarEXP = 0;
	
	public String BarType;
	public static int AmountOfCasts;
	public String ScreenShot;
	public String Calculate;
	public String Status;
	
	public String GUIString;
	public Object GUIString2;
	public Object GUIString3;
	public Object GUIString4;
	public boolean worked = false;

	//Some variables & anti-ban
	boolean start = true;
	boolean StartGUI = false;
	boolean checkObj = false;
	boolean checkXP = false;
	boolean doHover = false;
	public static int Percentage = 100;
	public static int AFK1, AFK2;
	public static int Mouse1 = 50;
	public int Mouse2 = 8;
	
	boolean useFKeys = false;
	boolean bankTwice = false;
	public int OpenedBank = 0;
	public boolean Continue = false;
	public boolean BankTime = false;
	public boolean DirectHeat = false;
	public boolean TabIsOpen = false;
	public boolean TakeAShot = false;
	public boolean DoTheMath = false;
	public int Option = 1;

	public int barType = 0;
	public int BarID = 0;
	public int Ore1 = 0;
	public int Ore2 = 0;
	public int Ore1WD = 0;
	public int Ore2WD = 0;
	public int Ore2PerSpell = 0;
	public int Ore1InvAm = 0;
	public int Ore2InvAm = 0;
	
	//Ore ID's
	public int copperOre = 436;
	public int tinOre = 438;
	public int ironOre = 440;
	public int silverOre = 442;
	public int goldOre = 444;
	public int coalOre = 453;
	public int mithrilOre = 447;
	public int adamantOre = 449;
	public int runeOre = 451;
	//Bar ID's
	public int bronzeBar = 2349;
	public int ironBar = 2351;
	public int steelBar = 2353;
	public int silverBar = 2355;
	public int goldBar = 2357;
	public int mithrilBar = 2359;
	public int adamantBar = 2361;
	public int runeBar = 2363;

	public int nature = 561;
		
	//Item prices from G.E
	public int BarPrice = 0;
	public int Ore1Price = 0;
	public int Ore2Price = 0;
	public int naturePrice = 0;
		
	/*-------------------------------------------------------------------
	 * ------------------   P   A   I   N   T   -------------------------
	 ------------------------------------------------------------------*/
	public void onRepaint(Graphics g) {
		runTime = System.currentTimeMillis() - scriptStartTime;
		seconds = runTime / 1000;
		if (startXPM == 0){
			startXPM = skills.getCurrentExp(Skills.MAGIC);
		}
		if (startXPS == 0){
			startXPS = skills.getCurrentExp(Skills.SMITHING);
		}
        if ( startLevelM == 0 ) {
            startLevelM = skills.getCurrentLevel(Skills.MAGIC);
		}
        if ( startLevelS == 0 ) {
        	startLevelS = skills.getCurrentLevel(Skills.SMITHING);
        }
        int XPGainedSmithing = 0;
		int XPGainedMagic = 0;
		XPGainedMagic = (skills.getCurrentExp(Skills.MAGIC) - startXPM);
		final int XPHRM = (int) ((XPGainedMagic) * 3600000D / (System.currentTimeMillis() - startTime));
		XPGainedSmithing = (skills.getCurrentExp(Skills.SMITHING) - startXPS);
		BarCounter = (XPGainedMagic/53);
		final int XPHRS = (int) ((XPGainedSmithing) * 3600000D / (System.currentTimeMillis() - startTime));
		final int profit = (int) ((BarPrice) - (Ore1Price) - (Ore2Price) - (naturePrice));
		final int ProfitHR = (int) ((profit * BarCounter) * 3600000D / (System.currentTimeMillis() - startTime));
        levelsGainedM = skills.getCurrentLevel(Skills.MAGIC) - startLevelM;
        levelsGainedS = skills.getCurrentLevel(Skills.SMITHING) - startLevelS;
        currentLevelM = skills.getCurrentLevel(Skills.MAGIC);
        currentLevelS = skills.getCurrentLevel(Skills.SMITHING);
			millis = System.currentTimeMillis() - startTime;
			hours = millis / (1000 * 60 * 60);
			millis -= hours * (1000 * 60 * 60);
			minutes = millis / (1000 * 60);
			millis -= minutes * (1000 * 60);
			seconds = millis / 1000;
		//GENERAL					
			g.setColor(new Color(0, 0, 200, 130));
			g.fillRect(497, 458, 15, 14);	
			g.setColor(new Color(0, 0, 0, 255));
			g.drawRect(497, 458, 15, 14);
			g.setColor(new Color(255, 255, 255, 255));
			g.drawString(""+Option, 502, 470);
			toNextLvlS = skills.getPercentToNextLevel(Skills.SMITHING);
			XPToLevelS = skills.getExpToNextLevel(Skills.SMITHING);
			nextLvlS = skills.getCurrentLevel(Skills.SMITHING) + 1;
			toNextLvlM = skills.getPercentToNextLevel(Skills.MAGIC);
			XPToLevelM = skills.getExpToNextLevel(Skills.MAGIC);
			nextLvlM = skills.getCurrentLevel(Skills.MAGIC) + 1;
//OPTION 1
		if(Option == 1) {		
		//IMAGE
			g.drawImage(BKG, 7, 297, null);
			g.setFont(new Font("Verdana", 0, 9));
			g.setColor(Color.BLUE);
			g.drawString("v5.03", 441, 424);
		//TIME
			if(Status != "Loading...") {
				g.setFont(new Font("Verdana", 0, 13));
				g.setColor(Color.WHITE);
				g.drawString("" + hours + ":" + minutes + ":"	+ seconds + ".", 80, 437);
			} else {
				g.setFont(new Font("Verdana", 0, 13));
				g.setColor(Color.WHITE);
				g.drawString("Loading...", 80, 437);
			}
		//Status
			g.setFont(new Font("Verdana", 0, 9));
			g.drawString(""+Status, 40, 459);
		//Proggy bars & texts
			//Mage
			g.setFont(new Font("Verdana", 0, 9));
			g.setColor(new Color(0, 0, 0));
			g.fillRect(54, 359, 169, 16);
			g.drawRect(53, 358, 170, 17);
			g.setColor(new Color(51, 51, 51));
			g.fillRect(54, 359, 169, 8);
			g.setColor(new Color(90, 90, 255, 100));
			g.fillRect(56, 361, (int) (toNextLvlM * 165 / 100.0), 12);
			g.setColor(Color.WHITE);	
			g.drawString(""+toNextLvlM + "% to "+nextLvlM+" Mage ("+(XPToLevelM)/1000+"k Xp)", 70, 371);
			g.setColor(Color.CYAN);
			g.drawString("XP Gained: "+XPGainedMagic+" ("+XPHRM/1000+"k Xp/h)", 53, 391);
			g.drawString("Level: "+currentLevelM+" ("+levelsGainedM+")", 53, 404);
			//Smith
			g.setFont(new Font("Verdana", 0, 9));
			g.setColor(new Color(0, 0, 0));
			g.fillRect(263, 359, 169, 16);
			g.drawRect(262, 358, 170, 17);
			g.setColor(new Color(51, 51, 51));
			g.fillRect(263, 359, 169, 8);
			g.setColor(new Color(250, 150, 70, 100));
			g.fillRect(265, 361, (int) (toNextLvlS * 165 / 100.0), 12);
			g.setColor(Color.WHITE);	
			g.drawString(""+toNextLvlS + "% to "+nextLvlS+" Smith ("+(XPToLevelS)/1000+"k Xp)", 279, 371);
			
			g.drawString("XP Gained: "+XPGainedSmithing+" ("+XPHRS/1000+"k Xp/h)", 262, 391);
			g.drawString("Level: "+currentLevelS+" ("+levelsGainedS+")", 262, 404);
			//PROFIT
			g.setColor(Color.YELLOW);
			if(DoTheMath == true) {
				g.drawString("Profit: " +profit * BarCounter+" ("+ProfitHR/1000+"k/h)", 262, 429);
				g.drawString("Profit/"+BarType+" Bar: "+profit, 262, 455);
			}
			g.drawString("Bars: " +BarCounter+" "+BarType+" Bars"+" ("+XPHRM/53+"/h)", 262, 442);
			//Bars left
			if(AmountOfCasts > 0) {
				g.setFont(new Font("Verdana", 0, 9));
				g.setColor(Color.RED);
				g.drawString("Casts left: " +(AmountOfCasts - BarCounter), 390, 15);
			}
		}
//OPTION 2
		if(Option == 2) {
		//IMAGE
			g.drawImage(BKG, 16, 154, null);
			g.setFont(new Font("Verdana", 0, 9));
			g.setColor(Color.BLUE);
			g.drawString("v5.03", 450, 281);
		//TIME
			if(Status != "Loading...") {
				g.setFont(new Font("Verdana", 0, 13));
				g.setColor(Color.WHITE);
				g.drawString("" + hours + ":" + minutes + ":"	+ seconds + ".", 89, 294);
			} else {
				g.setFont(new Font("Verdana", 0, 13));
				g.setColor(Color.WHITE);
				g.drawString("Loading...", 89, 294);
			}
		//Status
			g.setFont(new Font("Verdana", 0, 9));
			g.drawString(""+Status, 49, 316);
		//Proggy bars & texts
			//Mage
			g.setFont(new Font("Verdana", 0, 9));
			g.setColor(new Color(0, 0, 0));
			g.fillRect(63, 216, 169, 16);
			g.drawRect(62, 215, 170, 17);
			g.setColor(new Color(51, 51, 51));
			g.fillRect(63, 216, 169, 8);
			g.setColor(new Color(90, 90, 255, 100));
			g.fillRect(65, 218, (int) (toNextLvlM * 165 / 100.0), 12);
			g.setColor(Color.WHITE);	
			g.drawString(""+toNextLvlM + "% to "+nextLvlM+" Mage ("+(XPToLevelM)/1000+"k Xp)", 70, 228);
			g.setColor(Color.CYAN);
			g.drawString("XP Gained: "+XPGainedMagic+" ("+XPHRM/1000+"k Xp/h)", 62, 248);
			g.drawString("Level: "+currentLevelM+" ("+levelsGainedM+")", 62, 261);
			//Smith
			g.setFont(new Font("Verdana", 0, 9));
			g.setColor(new Color(0, 0, 0));
			g.fillRect(272, 216, 169, 16);
			g.drawRect(271, 215, 170, 17);
			g.setColor(new Color(51, 51, 51));
			g.fillRect(272, 216, 169, 8);
			g.setColor(new Color(250, 150, 70, 100));
			g.fillRect(274, 218, (int) (toNextLvlS * 165 / 100.0), 12);
			g.setColor(Color.WHITE);	
			g.drawString(""+toNextLvlS + "% to "+nextLvlS+" Smith ("+(XPToLevelS)/1000+"k Xp)", 288, 228);
			
			g.drawString("XP Gained: "+XPGainedSmithing+" ("+XPHRS/1000+"k Xp/h)", 271, 248);
			g.drawString("Level: "+currentLevelS+" ("+levelsGainedS+")", 271, 261);
			//PROFIT
			g.setColor(Color.YELLOW);
			if(DoTheMath == true) {
				g.drawString("Profit: " +profit * BarCounter+" ("+ProfitHR/1000+"k/h)", 271, 286);
				g.drawString("Profit/"+BarType+" Bar: "+profit, 271, 312);
			}
			g.drawString("Bars: " +BarCounter+" "+BarType+" Bars"+" ("+XPHRM/53+"/h)", 271, 299);
			//Bars left
			if(AmountOfCasts > 0) {
				g.setFont(new Font("Verdana", 0, 9));
				g.setColor(Color.RED);
				g.drawString("Casts left: " +(AmountOfCasts - BarCounter), 390, 15);
			}
		}
	}
	/*------------------------------------------------------------
	 * ------------------  O N   S T A R T  ----------------------
	 -----------------------------------------------------------*/
	@Override
	public boolean onStart() {
		Status = "Loading...";
		try {
			BKG = ImageIO.read(new URL("http://a.imageshack.us/img14/5392/superheater50paint.png"));
		} catch (final java.io.IOException e) {
			e.printStackTrace();
		}
		
		SuperheaterGUI = new GUI(this);
		SuperheaterGUI.setLocationRelativeTo(null);
		SuperheaterGUI.setVisible(true);

		while(WaitForStart){
			sleep(20);
		}
		
		if(worked == false) return false;
			if(DoTheMath == true) {
				log("Obtaining G.E prices...");
				final GEItemInfo BarGE = grandExchange.loadItemInfo(BarID); 
				BarPrice = BarGE.getMarketPrice();
				final GEItemInfo Ore1GE = grandExchange.loadItemInfo(Ore1);
				Ore1Price = Ore1GE.getMarketPrice();
				final GEItemInfo Ore2GE = grandExchange.loadItemInfo(Ore2);
				Ore2Price = Ore2GE.getMarketPrice() * Ore2PerSpell;
				final GEItemInfo natureGE = grandExchange.loadItemInfo(nature);
				naturePrice = natureGE.getMarketPrice(); 
				log("... prices retrieved!" + "  ||  Profit/Bar: " + (BarPrice) + " - " + (Ore1Price) + " - " + (Ore2Price) + " - " + (naturePrice) + " = " + (BarPrice - Ore1Price - Ore2Price - naturePrice));
			}
			if(barType != 5) {
				log("Magic XP/Cast: 53  ||  Smithing XP/"+BarType +" bar: "+BarEXP);
			} else {
				log("Magic XP/Cast: 53  ||  Smithing XP/"+BarType +" bar: "+BarEXP +" (" +"56.2" +")");
			}
			mouse.setSpeed(Mouse2);
			log(" ~ Anti-ban synchronized to "+Percentage + "% efficiency! || Mousespeed set to "+Mouse1 + "%! ~");
			startTime = System.currentTimeMillis();
			if(TakeAShot == true) {
				log("Will take a screenshot when finished, Fallen's Superheater is now running!");
			} else {
				log("Fallen's Superheater is now running!");
			}
			if (AmountOfCasts != 0) {
				log("Logging out after " + AmountOfCasts + " casts!");
			}
			log("------------------------------------------------");
		return true;
	}
	
//************************************************************************************************************
	private State getState() {
		if(DirectHeat == true || Continue == true) {
			return State.SUPERHEAT;
		} else 
		if(DirectHeat == false && Continue == false) {
			final int ore1Count = inventory.getCount(Ore1);
			final int ore2Count = inventory.getCount(Ore2);
			if (ore1Count < 1 || ore2Count < Ore2PerSpell || ore1Count > Ore1InvAm || ore2Count > Ore2InvAm) {
					if (bank.isOpen()) {
						return State.BANK;
					} else {
						return State.OPENBANK;
					}
			} else {
				if(!bank.isOpen()) {
					return State.SUPERHEAT;
				} else {
					return State.BANK;
				}
			}
		} else {
			return State.SUPERHEAT;
		}
	}
//************************************************************************************************************
	@Override
	public int loop() {
				final State state = getState(); //Gets the state	    
					switch (state) { //Switches between these states based on getState
						case SUPERHEAT:
							Status = "Superheating.";
							DirectHeat = false;
							TabIsOpen = false;
					    	if (game.getCurrentTab() != Game.TAB_MAGIC) {
					    		game.openTab(Game.TAB_MAGIC);
					    	}
							if(!bank.isOpen()) {
								magic.castSpell(Magic.SPELL_SUPERHEAT_ITEM);
								waitForTab(Game.TAB_INVENTORY, 2000);
							} else {
								break;
							}
							if(!bank.isOpen() && game.getCurrentTab() == Game.TAB_INVENTORY) {
							final int ore1Count = inventory.getCount(Ore1);
							final int ore2Count = inventory.getCount(Ore2);
									if((ore1Count > 1 && bankTwice == false) || (bankTwice == true && ore1Count > 1 && ore2Count > Ore2PerSpell)) {
										Continue = true;
										BankTime = false;
									} else
									if(ore1Count == 1 || ore1Count == 0) {
										Continue = false;
										BankTime = true;
									}
									if(atLastInventoryItem(Ore1, "Cast")) {
										if(useFKeys == true) {
											sleep(random(100,200));
											keyboard.pressKey((char) KeyEvent.VK_F4);
											sleep(random(50,150));
											keyboard.releaseKey((char) KeyEvent.VK_F4);
										}
										AntiBan();
										waitForMageTabWO(2500);
										if ((AmountOfCasts) != 0) {
											if (BarCounter >= AmountOfCasts) {
												Quit();
												log("Goal achieved!");
											}
										}
									} else {
										atLastInventoryItem(Ore1, "Cast");
										if(useFKeys == true) {
											sleep(random(100,200));
											keyboard.pressKey((char) KeyEvent.VK_F4);
											sleep(random(50,150));
											keyboard.releaseKey((char) KeyEvent.VK_F4);
										}
										AntiBan();
										waitForMageTabWO(2500);
										if ((AmountOfCasts) != 0) {
											if (BarCounter >= AmountOfCasts) {
												Quit();
												log("Goal achieved!");
											}
										}
									}
							}
							if (BankTime == true && Continue == false) {
								Status = "Opening the bank.";
									bank.open();
									mouse.moveRandomly(50);
									if(waitForIF(interfaces.get(Bank.INTERFACE_BANK ),2000) == true) {
										sleep(random(100,200));
									} else {
										bank.open();
										mouse.moveRandomly(50);
										waitForIF(interfaces.get(Bank.INTERFACE_BANK ),2000);
										sleep(random(100,200));
									}
									BankTime = false;
									TabIsOpen = true;
							}
							break;
						case OPENBANK:
							Status = "Opening the bank.";
							if (OpenedBank < 2) {
								bank.open();
								mouse.moveRandomly(50);
								if(waitForIF(interfaces.get(Bank.INTERFACE_BANK ),2000) == true) {
									sleep(random(100,200));
									OpenedBank++;
								} else {
									bank.open();
									mouse.moveRandomly(50);
									waitForIF(interfaces.get(Bank.INTERFACE_BANK ),2000);
									sleep(random(100,200));
									OpenedBank++;
								}
							} else {
								game.openTab(random(0,17));
								sleep(random(300,600));
								game.openTab(Game.TAB_INVENTORY);
								OpenedBank = 0;
							}
							break;
						case BANK:
							Status = "Banking.";
							if(!bank.isOpen()) {
								break;
							}
							OpenedBank = 0;
							final int ore1Count2 = inventory.getCount(Ore1);
							final int ore2Count2 = inventory.getCount(Ore2);
									bank.depositAllExcept(nature, Ore1, Ore2);
									if (bankTwice == true) {
														if (ore1Count2 == 0) {
															CheckOres1();
															withdraw(Ore1, Ore1WD);
															waitForWithdrawnItem(Ore1, 1500);
															break;
														} else
														if (ore1Count2 > 0 && ore1Count2 < Ore1WD) {	
																if (ore2Count2 <= Ore2InvAm) {
																	bank.depositAllExcept(nature, Ore2);
																} else
																if (ore2Count2 > Ore2InvAm) {
																	bank.depositAllExcept(nature);
																}
															CheckOres1();
															withdraw(Ore1, Ore1WD);
															waitForWithdrawnItem(Ore1, 1500);
															break;
														} else
														if (ore1Count2 > Ore1InvAm) {	
															bank.depositAllExcept(nature, Ore2);
															CheckOres1();
															withdraw(Ore1, Ore1WD);
															waitForWithdrawnItem(Ore1, 1500);
															break;
														} else
														if (ore1Count2== Ore1WD && ore2Count2 != Ore2InvAm) {
																if (ore2Count2 == 0) {
																	CheckOres2();
																	withdraw(Ore2, Ore2WD);
																	waitForWithdrawnItem(Ore2, 1500);
																	break;
																} else
																if (ore2Count2 > 7 && ore2Count2 != Ore2InvAm) {	
																	bank.depositAllExcept(nature, Ore1);
																	CheckOres2();
																	withdraw(Ore2, Ore2WD);
																	waitForWithdrawnItem2(Ore2, 1500);
																	break;
																} else
																if (ore2Count2 > 0 && ore2Count2 < 7) {	
																	CheckOres2();
																	withdraw(Ore2, Ore2WD);
																	waitForWithdrawnItem2(Ore2, 1500);
																	break;
																} else
																if (ore2Count2 > Ore2InvAm) {	
																	bank.depositAllExcept(nature, Ore1);
																	CheckOres2();
																	withdraw(Ore2, Ore2WD);
																	waitForWithdrawnItem2(Ore2, 1500);
																	break;
																}
														} else
														if(ore1Count2== Ore1InvAm && ore2Count2 == Ore2InvAm){
															if(TabIsOpen == true) {
																DirectHeat = true;
															}
															BankTime = false;
															bank.close();
															break;
														}
									} else
									if (bankTwice == false) {
												if (ore1Count2 == 0) {
													CheckOres1();
													withdraw(Ore1, Ore1WD);
													waitForWithdrawnItem(Ore1, 1500);
													break;
												} else if (ore1Count2 > Ore1InvAm) {
													bank.depositAllExcept(nature);
													break;
												} else
												if(ore1Count2 > 0){
													if(TabIsOpen == true) {
														DirectHeat = true;
													}
													BankTime = false;
													bank.close();
													break;
												}
									}
							break;
				}
		return 50;
	}
	
/* ------------------------------------------------------------------------------------------------------------------------------
 * ------------------------------------------------------------------------------------------------------------------------------
 * ---------------------------------------     M   E   T   H   O   D   S     ----------------------------------------------------
 * ------------------------------------------------------------------------------------------------------------------------------
 ------------------------------------------------------------------------------------------------------------------------------*/	
	public boolean waitForIF(RSInterface iface, int timeout) {
		long start = System.currentTimeMillis();

		while (System.currentTimeMillis() - start < timeout) {
			if (iface.isValid()) {
					return true;
			}
			sleep(100);
		}
		return false;
	}
	
	public boolean waitForMageTabWO(int timeout) {
		long start = System.currentTimeMillis();

		while (System.currentTimeMillis() - start < timeout) {
			if (game.getCurrentTab() == Game.TAB_MAGIC) {
					break;
			}
			sleep(100);
		}
		if (game.getCurrentTab() != Game.TAB_MAGIC);
		return false;
	}
	
	public boolean waitForTab(int tab, int timeout) {
		long start = System.currentTimeMillis();
		while (System.currentTimeMillis() - start < timeout) {
			if (game.getCurrentTab() == tab) {
					break;
			}
			sleep(100);
		}
		if (game.getCurrentTab() != tab);
		return false;
	}
	
	public boolean atLastInventoryItem(int itemID, String option) {
		try {
			if (game.getCurrentTab() != Game.TAB_INVENTORY && !interfaces.get(Bank.INTERFACE_BANK).isValid()) {
				game.openTab(Game.TAB_INVENTORY);
			}
			RSComponent iinventory = inventory.getInterface();
			if (iinventory == null || iinventory.getComponents() == null)
				return false;

			java.util.List<RSComponent> possible = new ArrayList<RSComponent>();
			for (RSComponent item : iinventory.getComponents()) {
				if (item != null && item.getComponentID() == itemID) {
					possible.add(item);
				}
			}
			if (possible.size() == 0)
				return false;
			RSComponent item = possible.get(random(possible.size() - 1, possible.size()));
			return (item).doAction(option);
		} catch (Exception e) {
			log("atInventoryItem(int itemID, String option) Error: " + e);
			return false;
		}
	}
	
	private boolean withdraw(int itemID, int amount) {
		String s = amount + "";
		if (bank.isOpen()) {
			if (amount > 0) {
				if (!bank.getItem(itemID).doAction(s)) {
					if (bank.getItem(itemID).doAction("X")) {
						sleep(random(2000, 2500));
						sleep(random(100, 200));
						keyboard.sendText(s, false);
						sleep(random(800, 1000));
						keyboard.sendText("", true);
						return true;
					}
					return true;
				}
			} else {
				return bank.getItem(itemID).doAction("All");
			}
		}
		return false;
	}
	
	public int waitForWithdrawnItem(int item, int timeout) {
		long start = System.currentTimeMillis();

		while (System.currentTimeMillis() - start < timeout) {
			if (inventory.getCount(item) > 0) {
					break;
			}
			sleep(100);
		}
		return inventory.getCount(item);
	}
		
	public int waitForWithdrawnItem2(int item, int timeout) {
		final int currentAmount;
		long start = System.currentTimeMillis();
		currentAmount = inventory.getCount(item);

		while (System.currentTimeMillis() - start < timeout) {
			if (inventory.getCount(item) > currentAmount) {
					break;
			}
			sleep(100);
		}
		return inventory.getCount(item);
	}

//************************************************************************************************************
		
	public void CheckOres1() {
		if (bank.isOpen() && bank.getCount(Ore1) < Ore1InvAm) {
			Status = "Out of ores? Checking...";
			sleep(random(1000, 1500));
			log("Out of ores - Check: 1/3");
			if (bank.isOpen() && bank.getCount(Ore1) < Ore1InvAm) {
				sleep(random(1000, 1500));
				log("Out of ores - Check: 2/3");
				if (bank.isOpen() && bank.getCount(Ore1) < Ore1InvAm) {
					sleep(random(1000, 1500));
					log("Out of ores - Check: 3/3!");
					bank.close();
					Quit();
				}
			}
		}
	}

	public void CheckOres2() {
		if (bankTwice == true) {
			if (bank.isOpen() && bank.getCount(Ore2) < Ore2InvAm) {
				Status = "Out of ores? Checking...";
				sleep(random(1000, 1500));
				log("Out of ores - Check: 1/3");
				if (bank.isOpen() && bank.getCount(Ore2) < Ore2InvAm) {
					sleep(random(1000, 1500));
					log("Out of ores - Check: 2/3");
					if (bank.isOpen() && bank.getCount(Ore2) < Ore2InvAm) {
						sleep(random(1000, 1500));
						log("Out of ores - Check: 3/3!");
						bank.close();
						Quit();
					}
				}
			}
		}
	}
		
	public void Quit() {
		Status = "Quitting.";
		if (TakeAShot == true) {
			env.saveScreenshot(true);
			log("Screenshot taken!");
			sleep(500);
		}
		stopScript();
	}
		
	/* ---------------------------------------------------------------------------------------------------
	 * ---------------------------------------------------------------------------------------------------
	 * --------------------------------   A N T I - B A N   ----------------------------------------------
	 * ----------------------------------------------------------- Standard & While banking --------------
	   -------------------------------------------------------------------------------------------------*/
	boolean hoverPlayer() {
		RSPlayer player = null;
		RSPlayer[] validPlayers = players.getAll();

		player = validPlayers[random(0, validPlayers.length - 1)];
		if(player != null) {
			try {
				String playerName = player.getName();
				String myPlayerName = getMyPlayer().getName();
			if (playerName.equals(myPlayerName)) {
				return false;
			}
			} catch(NullPointerException e) {}
			try {
				RSTile targetLoc = player.getLocation();
				String name = player.getName();
				Point checkPlayer = calc.tileToScreen(targetLoc);
				if (calc.pointOnScreen(checkPlayer) && checkPlayer != null) {
					mouse.click(checkPlayer, 5, 5, false);
					log("ANTIBAN - Hover Player - Right click on " + name);
				} else {
					return false;
				}
				return true;
			} catch (Exception ignored) {
			}
		}
		return false;
	}
    
	public void hoverObject() {
		examineRandomObject(5);
		sleep(randGenerator(50, 1000));
		int mousemoveAfter2 = randGenerator(0, 4);
		sleep(randGenerator(100, 800));
		if (mousemoveAfter2 == 1 && mousemoveAfter2 == 2) {
			mouse.move(1, 1, 760, 500);
		}
	}
	
    int randGenerator(int min, int max) {
        return min + (int) (java.lang.Math.random() * (max - min));
    }
	
    public RSTile examineRandomObject(int scans) {
        RSTile start = getMyPlayer().getLocation();
        ArrayList<RSTile> possibleTiles = new ArrayList<RSTile>();
        for(int h = 1; h < scans * scans; h += 2) {
            for(int i = 0; i < h; i++) {
                for(int j = 0; j < h; j++) {
                    int offset = (h + 1)/2 - 1;
                    if(i > 0 && i < h - 1) {
                        j = h - 1;
                    }
                    RSTile tile = new RSTile(start.getX() - offset + i, start.getY() - offset + j);
                    RSObject objectToList = objects.getTopAt(tile);
                    if(objectToList!= null && calc.tileOnScreen(objectToList.getLocation())
                            && objectToList.getLocation().isValid()) {
                        possibleTiles.add(objectToList.getLocation());
                    }
                }
            }
        }
        if (possibleTiles.size() == 0) {
            return null;
        }
        if(possibleTiles.size() > 0 && possibleTiles != null) {
            final RSTile objectLoc = possibleTiles.get(randGenerator(0,possibleTiles.size()));
            Point objectPoint = calc.tileToScreen(objectLoc);
            if(objectPoint != null) {
                try {
                    mouse.move(objectPoint);
                    if(menu.doAction("xamine")) {
                    } else {
                    }
                    sleep(random(100,500));
                } catch(NullPointerException ignored) {}
            }
        }
        return null;
    }
	/* ----------------------------------
	 * ------------ Standard ------------
	   --------------------------------*/
	public void AntiBan() {
			int chckObj = random(1,(13000/Percentage));
			int hover = random(1,(10000/Percentage));
			int checkxp = random(1,(13000/Percentage));
			int afk = random(1,(10000/Percentage));
			int camerahh = random(1,(2000/Percentage));
			int hoverObject = random(1,(8000/Percentage));	
		if(Percentage != 0) {

			
			if (chckObj == 5) {
				waitForMageTabWO(1500);
				Status = "ANTIBAN - Checking objective.";
				game.openTab(Game.TAB_SUMMONING);
				sleep(random(300,500));
				mouse.move(644,394,51,6);
				sleep(random(900,1600));
				mouse.move(644,394,51,6);
				sleep(random(500,1000));
				mouse.moveRandomly(500);
				sleep(random(400,900));
				game.openTab(Game.TAB_MAGIC);
			} else if (hover == 5) {
				Status = "ANTIBAN - Clicking a player.";
				hoverPlayer();
	            sleep(random(1150,2800));
	                mouse.moveRandomly(750);
	                sleep(random(400, 1000));         } 
			} else if (hoverObject == 5) {
				Status = "ANTIBAN - Clicking an object.";
				hoverObject();
	            sleep(random(1150,2800));
	                mouse.moveRandomly(750);
	                sleep(random(400, 1000));
			} else if (checkxp == 5) {
				waitForMageTabWO(1500);
				Status = "ANTIBAN - XP Check.";
		    	final int GambleInt5 = random(0,100);
	    		if (GambleInt5 > 50) {
					game.openTab(Game.TAB_STATS);
					sleep(random(400,800));
					mouse.move(584, 364, 20, 10); //Magic LvL
			        sleep(random(800,1200));
					mouse.move(584, 364, 20, 10); //Magic LvL
			       	sleep(random(900,1750));
			       	mouse.moveRandomly(700);
			       	sleep(random(300,800));
			       	game.openTab(Game.TAB_MAGIC);
	    		} else
	    		if (GambleInt5 < 51) {
					game.openTab(Game.TAB_STATS);
					sleep(random(400,800));
					mouse.move(707, 252, 20, 10); //Smithing LvL
			        sleep(random(800,1200));
					mouse.move(707, 252, 20, 10); //Smithing LvL
			       	sleep(random(900,1750));
			       	mouse.moveRandomly(700);
			       	sleep(random(300,800));
			       	game.openTab(Game.TAB_MAGIC);		
	    		}
			} else if (afk == 5) {
				switch(random(1,4)) {
				case 1:
					Status = "ANTIBAN - AFK'ing.";
					sleep(random(AFK1,AFK2));
					break;
				case 2:
					Status = "ANTIBAN - AFK'ing.";
					sleep(random(AFK1/4,AFK2/10));
					mouse.moveRandomly(750);
	                sleep(random(AFK1,AFK2));
	                break;			
				case 3:
					Status = "ANTIBAN - AFK'ing.";
					sleep(random(0,500));
					mouse.moveRandomly(1000);
					sleep(random(AFK1/4,AFK2/10));
					mouse.moveRandomly(1500);
					sleep(random(AFK1,AFK2));
	                break;	
				}		 
			} else if (camerahh == 5) {
				int randomTurn = random(1,4);
	            switch(randomTurn) {
	                case 1:
	                    new CameraRotateThread().start();
	                    break;
	                case 2:
	                    new CameraHeightThread().start();
	                    break;
	                case 3:
	                    int randomFormation = random(0,2);
	                    if(randomFormation == 0) {
	                        new CameraRotateThread().start();
	                        new CameraHeightThread().start();
	                    } else {
	                        new CameraHeightThread().start();
	                        mouse.moveRandomly(200);
	                        new CameraRotateThread().start();
	                    }
	            }
			}
			return;
		}	
	public class CameraRotateThread extends Thread {
		@Override
		public void run() {
			char LR = KeyEvent.VK_RIGHT;
			if (random(0, 2) == 0) {
				LR = KeyEvent.VK_LEFT;
			}
			keyboard.pressKey(LR);
			try {
				Thread.sleep(random(450, 2600));
			} catch (final Exception ignored) {
			}
			keyboard.releaseKey(LR);
		}
	}

	public class CameraHeightThread extends Thread {

		@Override
		public void run() {
			char UD = KeyEvent.VK_UP;
			if (random(0, 2) == 0) {
				UD = KeyEvent.VK_DOWN;
			}
			keyboard.pressKey(UD);
			try {
				Thread.sleep(random(450, 1700));
			} catch (final Exception ignored) {
			}
			keyboard.releaseKey(UD);
		}
	}
			/* ----------------------------------
			 * -------- While banking --------
			   --------------------------------*/
			 public void bankingAntiBan() {
				 if((random(0,(400/Percentage)) == 2)) {
					int randomTurn = random(1,4);
			        switch(randomTurn) {
			            case 1:
			                new CameraRotateThread().start();
			                break;
			            case 2:
			                new CameraHeightThread().start();
			                break;
			            case 3:
			                int randomFormation = random(0,2);
			                if(randomFormation == 0) {
			                    new CameraRotateThread().start();
			                    new CameraHeightThread().start();
			                } else {
			                    new CameraHeightThread().start();
			                    new CameraRotateThread().start();
			                }
			                break;
			        }
				 }
		 }	
//************************************************************************************************************
	 @Override
	 public void serverMessageRecieved(ServerMessageEvent msg) {
	    	String message = msg.getMessage().toLowerCase();
	    	if (message.contains("have enough nat")) {
	    		log("Out of nature runes!");
	    		Quit();
	    	} else if (message.contains("have enough fir")) {
	    		log("Out of fire runes!");
	        	log("Please equip a staff with unlimited fire runes.");
	        	Quit();
	    	}
	    }
//************************************************************************************************************	
	@Override
	public void onFinish() {
		log(+ BarCounter + " " + BarType + " bars made in: "+hours+":"+minutes+":"+seconds+".");
		log("Thank you for using Fallen's Superheater.");
	}
//************   G U I   **************************************************************************************
	public boolean WaitForStart = true;
	GUI SuperheaterGUI;
	
	public class GUI extends JFrame implements WindowListener {

		private static final long serialVersionUID = -34342;
		private JPanel contentPane;
		private JPanel Panel1;
		private JPanel Panel2;
		private JPanel Panel3;
		private JTabbedPane TabbedPanel;
		private JButton startButton;
		private JButton exitButton;
		private JRadioButton Box1;
		private JRadioButton Box2;
		private JRadioButton Box3;
		private JRadioButton Box4;
		private JComboBox Options;
		private JLabel OptionText;
		private JLabel BoxText;
		private JLabel Slider1Text;
		private JLabel Slider2Text;
		private JLabel FieldText1;
		private JLabel FieldText2;
		private JLabel FieldText3;
		private JFormattedTextField TextField;
		private JFormattedTextField TextField2;
		private JFormattedTextField TextField3;
		private JTextPane TextPanel;
		private JSlider Slider1;
		private JSlider Slider2;
		FallenSuperheater script;

		public GUI(final FallenSuperheater Superheater) {
			script = Superheater;
			initComponents();
		}
		
		private void initComponents() {

			addWindowListener(this);
			contentPane = (JPanel) this.getContentPane(); 
			contentPane.setLayout(null);
			contentPane.setOpaque(false);
			
			TabbedPanel = new JTabbedPane();
			Panel1 = new JPanel();
			Panel2 = new JPanel();
			Panel3 = new JPanel();
			TabbedPanel.setFont(new Font("Verdana",Font.PLAIN, 12));
			TabbedPanel.setBorder(null);
			TabbedPanel.setFocusable(false);
			TabbedPanel.addTab("General", Panel1);
			TabbedPanel.addTab("Anti-Ban", Panel2);
			TabbedPanel.addTab("Info", Panel3);
			Panel1.setFont(new Font("Verdana", Font.PLAIN, 12));
			Panel1.setFocusable(false);
			Panel1.setLayout(null);
			Panel2.setFont(new Font("Verdana", Font.PLAIN, 12));
			Panel2.setFocusable(false);
			Panel2.setLayout(null);
			Panel3.setFont(new Font("Verdana", Font.PLAIN, 12));
			Panel3.setFocusable(false);
			Panel3.setLayout(null);
			
			startButton = new JButton();
			startButton.setFont(new Font("Verdana", Font.PLAIN, 12));
			startButton.setText("Start");
			startButton.setEnabled(true);
			startButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(final java.awt.event.ActionEvent evt) {
					startButtonActionPerformed();
				}
			});
			exitButton = new JButton();
			exitButton.setText("Cancel");
			exitButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(final java.awt.event.ActionEvent evt) {
					exitButtonActionPerformed();
				}
			});
			
	//GENERAL
			String[] types = { "Bronze", "Iron", "Steel", "Silver", "Gold", "Mithril", "Adamantite", "Runite" };
			Options = new JComboBox(types);
			OptionText = new JLabel();
			OptionText.setFont(new Font("Verdana", Font.PLAIN, 14));
			OptionText.setText("Which bars to make?");
			Options.setBorder(null);
			Options.setOpaque(false);
			Options.setFocusable(false);
			
			TextField = new JFormattedTextField();
			TextField.setValue("5000");
			TextField.setEnabled(false);
			BoxText = new JLabel();
			BoxText.setText("Casts");
			BoxText.setEnabled(false);
			Box1 = new JRadioButton();
			Box1.setText("Log out after...");
			Box1.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(final java.awt.event.ActionEvent evt) {
					Box1ButtonActionPerformed();
				}
			});
			Box2 = new JRadioButton();
			Box2.setText("Calculate prices?");
			Box2.setEnabled(true);
			Box2.setSelected(true);
			
			Box3 = new JRadioButton();
			Box3.setText("Take a screenshot when finished?");
			Box3.setEnabled(true);			
			
			Box4 = new JRadioButton();
			Box4.setText("Use F-Keys? [WARNING: EXTREMELY FAST.]");
			Box4.setEnabled(true);	
			
			Slider1Text = new JLabel();
			Slider1Text.setFont(new Font("Verdana", Font.PLAIN, 12));
			Slider1Text.setText("Mouse Speed (%)");
			Slider1Text.setEnabled(true);
			
			Slider1 = new JSlider();
			Slider1.setMaximum(100);
			Slider1.setMinimum(10);
			Slider1.setBorder(null);
			Slider1.setOpaque(false);
			Slider1.setPaintTicks(true);
			Slider1.setPaintLabels(true);
			Slider1.setSnapToTicks(true);
			Slider1.setMajorTickSpacing(10);
			Slider1.setValue(60);
			Slider1.setFocusable(false);

//ANTIBAN
			Slider2Text = new JLabel();
			Slider2Text.setFont(new Font("Verdana", Font.PLAIN, 12));
			Slider2Text.setText("Anti-Ban efficiency (%)");
			Slider2Text.setEnabled(true);
			
			Slider2 = new JSlider();
			Slider2.setMaximum(100);
			Slider2.setMinimum(10);
			Slider2.setBorder(null);
			Slider2.setOpaque(false);
			Slider2.setPaintTicks(true);
			Slider2.setPaintLabels(true);
			Slider2.setSnapToTicks(true);
			Slider2.setMajorTickSpacing(10);
			Slider2.setValue(50);
			Slider2.setFocusable(false);
			
			FieldText1 = new JLabel();
			FieldText1.setFont(new Font("Verdana", Font.PLAIN, 12));
			FieldText1.setText("AFK times (seconds): ");
			FieldText1.setEnabled(true);
			FieldText2 = new JLabel();
			FieldText2.setText("Min:");
			FieldText2.setEnabled(true);
			FieldText3 = new JLabel();
			FieldText3.setText("Max:");
			FieldText3.setEnabled(true);
			
			TextField2 = new JFormattedTextField();
			TextField2.setValue("2");
			TextField2.setEnabled(true);
			TextField3 = new JFormattedTextField();
			TextField3.setValue("10");
			TextField3.setEnabled(true);
			
//INFO			
			TextPanel = new JTextPane();
			TextPanel.setText("Fallen's Superheater AIO - v5.03\n\n Start the script at any bank. Have natures in your inventory and a staff with unlimited fire runes equipped.\n Place the ores in your bank so that they can be seen.");
			TextPanel.setEditable(false);
			TextPanel.setFont(new Font("Verdana",Font.PLAIN, 12));
			TextPanel.setBorder(new LineBorder(Color.black));
			
			
//PLACEMENT
			setSize(400,400);
			setTitle("Fallen's Superheater v5.03");
			addComponent(contentPane, startButton, 5, 270, 375, 55);
			addComponent(contentPane, exitButton, 140, 330, 100, 25);
			addComponent(contentPane, TabbedPanel, 5, 5, 375, 260);
			addComponent(Panel1, OptionText, 113, 10, 250, 25);
			addComponent(Panel1, Options, 150, 37, 70, 20);
			addComponent(Panel1, Box1, 5, 85, 108, 20);
			addComponent(Panel1, TextField, 115, 84, 100, 20);
			addComponent(Panel1, BoxText, 225, 85, 150, 20);
			addComponent(Panel1, Box2, 5, 105, 200, 20);
			addComponent(Panel1, Box3, 5, 125, 220, 20);
			addComponent(Panel1, Box4, 5, 145, 330, 20);
			addComponent(Panel1, Slider1Text, 128, 170, 200, 20);
			addComponent(Panel1, Slider1, 85, 185, 200, 50);
			addComponent(Panel2, Slider2Text, 115, 10, 200, 20);
			addComponent(Panel2, Slider2, 85, 25, 200, 50);
			addComponent(Panel2, FieldText1, 10, 105, 150, 50);
			addComponent(Panel2, FieldText2, 180, 120, 23, 20);
			addComponent(Panel2, TextField2, 206, 120, 30, 20);
			addComponent(Panel2, FieldText3, 250, 120, 27, 20);
			addComponent(Panel2, TextField3, 278, 120, 30, 20);
			addComponent(Panel3, TextPanel, 10, 10, 350, 210);
		}
			
			
	 	private void addComponent(Container container,Component c,int x,int y,int width,int height) 
	 	{ 
	 		c.setBounds(x,y,width,height); 
	 		container.add(c); 
	 	}	
		
		private void startButtonActionPerformed() {
			
			FallenSuperheater.Mouse1 = (int) Slider1.getValue();
			FallenSuperheater.Percentage = (int) Slider2.getValue();
			GUIString = Options.getSelectedItem().toString();
			GUIString2 = TextField.getValue();
			GUIString3 = TextField2.getValue();
			GUIString4 = TextField3.getValue();
			FallenSuperheater.AFK1 = Integer.parseInt((String) GUIString3);
			FallenSuperheater.AFK2 = Integer.parseInt((String) GUIString4);
			if (GUIString.equals("Bronze")) {
				barType = 1;
				BarID = bronzeBar;
				Ore1 = copperOre;
				Ore2 = tinOre;
				Ore1WD = 13;
				Ore2WD = 13;
				bankTwice = true;
				BarType = "Bronze";
				BarEXP = (int) 6.25;
				Ore2PerSpell = 1;
				Ore1InvAm = 13;
				Ore2InvAm = 13;
			}
			if (GUIString.equals("Iron")) {
				barType = 2;
				BarID = ironBar;
				Ore1 = ironOre;
				//Ore2 = ironOre;
				Ore1WD = 0;
				//Ore2WD = 0;
				bankTwice = false;
				BarType = "Iron";
				BarEXP = (int) 12.5;
				Ore2PerSpell = 0;
				Ore1InvAm = 27;
				Ore2InvAm = 0;
			}
			if (GUIString.equals("Steel")) {
				barType = 3;
				BarID = steelBar;
				Ore1 = ironOre;
				Ore2 = coalOre;
				Ore1WD = 9;
				Ore2WD = 0;
				bankTwice = true;
				BarType = "Steel";
				BarEXP = (int) 17.5;
				Ore2PerSpell = 2;
				Ore1InvAm = 9;
				Ore2InvAm = 18;
			}
			if (GUIString.equals("Silver")) {
				barType = 4;
				BarID = silverBar;
				Ore1 = silverOre;
				//Ore2 = silverOre;
				Ore1WD = 0;
				//Ore2WD = 0;
				bankTwice = false;
				BarType = "Silver";
				BarEXP = (int) 13.7;
				Ore2PerSpell = 0;
				Ore1InvAm = 27;
				Ore2InvAm = 0;
			}
			if (GUIString.equals("Gold")) {
				barType = 5;
				BarID = goldBar;
				Ore1 = goldOre;
				//Ore2 = goldOre;
				Ore1WD = 0;
				//Ore2WD = 0;
				bankTwice = false;
				BarType = "Gold";
				BarEXP = (int) 22.5;
				Ore2PerSpell = 0;
				Ore1InvAm = 27;
				Ore2InvAm = 0;
			}
			if (GUIString.equals("Mithril")) {
				barType = 6;
				BarID = mithrilBar;
				Ore1 = mithrilOre;
				Ore2 = coalOre;
				Ore1WD = 5;
				Ore2WD = 0;
				bankTwice = true;
				BarType = "Mithril";
				BarEXP = (int) 30;
				Ore2PerSpell = 4;
				Ore1InvAm = 5;
				Ore2InvAm = 22;
			}
			if (GUIString.equals("Adamantite")) {
				barType = 7;
				BarID = adamantBar;
				Ore1 = adamantOre;
				Ore2 = coalOre;
				Ore1WD = 3;
				Ore2WD = 0;
				bankTwice = true;
				BarType = "Adamant";
				BarEXP = (int) 37.5;
				Ore2PerSpell = 6;
				Ore1InvAm = 3;
				Ore2InvAm = 24;
			}
			if (GUIString.equals("Runite")) {
				barType = 8;
				BarID = runeBar;
				Ore1 = runeOre;
				Ore2 = coalOre;
				Ore1WD = 3;
				Ore2WD = 0;
				bankTwice = true;
				BarType = "Runite";
				BarEXP = (int) 50;
				Ore2PerSpell = 8;
				Ore1InvAm = 3;
				Ore2InvAm = 24;
			}
			//MOUSESPEED
			if(Mouse1 == 100) {
				Mouse2 = 3;
			} else
			if(Mouse1 == 90) {
				Mouse2 = 4;
			} else
			if(Mouse1 == 80) {
				Mouse2 = 5;
			} else
			if(Mouse1 == 70) {
				Mouse2 = 6;
			} else
			if(Mouse1 == 60) {
				Mouse2 = 7;
			} else
			if(Mouse1 == 50) {
				Mouse2 = 8;
			} else
			if(Mouse1 == 40) {
				Mouse2 = 9;
			} else
			if(Mouse1 == 30) {
				Mouse2 = 10;
			} else
			if(Mouse1 == 20) {
				Mouse2 = 11;
			} else
			if(Mouse1 == 10) {
				Mouse2 = 12;
			}
			if(Box2.isSelected()) {
				DoTheMath = true;
			}
			if(Box1.isSelected()) {				
				FallenSuperheater.AmountOfCasts = Integer.parseInt((String) GUIString2);
			}
			if(Box3.isSelected()) {
				TakeAShot = true;
			}
			if(Box4.isSelected()) {
				useFKeys = true;
			}
			
			script.WaitForStart = false;
			worked = true;
			dispose();
			
		}
		
		private void exitButtonActionPerformed() {
			WaitForStart = false;
			worked = false;
			dispose();
		}
		
		private void Box1ButtonActionPerformed() {
			if(!BoxText.isEnabled()) {
				BoxText.setEnabled(true);
				TextField.setEnabled(true);
			} else {
				BoxText.setEnabled(false);
				TextField.setEnabled(false);
			}
		}

		public void windowClosing(final WindowEvent arg0) {
			WaitForStart = false;
			worked = false;
			dispose();
		}
		public void windowActivated(final WindowEvent e) {
			toFront();
		}
		public void windowClosed(WindowEvent arg0) {
		}
		public void windowDeactivated(WindowEvent arg0) {
		}
		public void windowDeiconified(WindowEvent arg0) {
		}
		public void windowIconified(WindowEvent arg0) {
		}
		public void windowOpened(WindowEvent arg0) {			
		}

	}
	@Override
	public void mouseClicked(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void mousePressed(MouseEvent e) {
		Point p = new Point(e.getPoint());
		final Rectangle toggleRectangle = new Rectangle(497, 458, 15, 14);
		if(toggleRectangle.contains(p) && renew == true) {
			if (Option == 1) {
				Option = 2;
				renew = false;
			} else if (Option == 2) {
				Option = 3;
				renew = false;
			} else if (Option == 3) {
				Option = 1;
				renew = false;
			}
		}
	}
	@Override
	public void mouseReleased(MouseEvent e) {
		renew = true;
	}
	@Override
	public void mouseDragged(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void mouseMoved(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
}

